package Z.dailyExercise.April;

public class _633平方数之和 {
    public static void main(String[] args) {
        _633平方数之和 test = new _633平方数之和();
        test.judgeSquareSum(9);
    }
    /**
     * 二分
     * @param c
     * @return
     */

    public boolean judgeSquareSum(int c) {
        if(c <2 ||  (Math.sqrt(c)+1)%2 == 0 || (Math.sqrt(c))%2 == 0){
            return true;
        }
       int right = (int) Math.floor(Math.sqrt(c));
        int left = 0;
        while (left<= right){
            if (right*right + left*left < c){
                left++;
            }else if (right*right + left*left == c){
                return true;
            }else {
                right--;
            }
        }

        return false;



    }

}
